using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Wrath.Windows.Forms;
using System.IO;

namespace Wrath.RuleForge
{
    public partial class OutputForm : DockContent
    {
        public OutputForm()
        {
            InitializeComponent();

            EventBroker.RuleSetOpen += new EventBroker.PathEventHandler(EventBroker_RuleSetOpen);
#if DEBUG
            EventBroker.DebugMessage += new EventBroker.MessageEventHandler(EventBroker_DebugMessage);
#endif
        }

#if DEBUG
        void EventBroker_DebugMessage(EventBroker.MessageEventArgs messageEventArgs)
        {
            AddLine(messageEventArgs.Message);
        }
#endif

        void EventBroker_RuleSetOpen(EventBroker.PathEventArgs pathEventArgs)
        {
            AddLine(String.Format("\r\n == Loading RuleSet '{0}' ==", Path.GetDirectoryName(pathEventArgs.Path)));
        }

        private void toolStripButtonClear_Click(object sender, EventArgs e)
        {
            textBox.Clear();
        }

        private void AddLine(string line)
        {
            textBox.AppendText(line + "\r\n");
            textBox.Select(textBox.Text.Length - 1, 0);
            textBox.ScrollToCaret();
        }
    }
}